/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * Main.java
 *
 * Created on 21/11/2011, 20:42:22
 */

package oogenda.view;

import java.awt.BorderLayout;
import javax.swing.JPanel;
import oogenda.util.DadosObjetos;

/**
 *
 * @author Pablo
 */
public class Main extends javax.swing.JFrame {

    /** Creates new form Main */
    public Main(String titulo) {
        super(titulo);
        initComponents();
        DadosObjetos.inicializarDias();
        DadosObjetos.inicializarDatas();
        DadosObjetos.inicializarDiasExame();
        DadosObjetos.inicializarDatasExame();
        DadosObjetos.inicializarPacientes();
        DadosObjetos.inicializarEspecialidades();
        DadosObjetos.inicializarMedicos();
        DadosObjetos.inicializarExames();
        
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        jButton1 = new javax.swing.JButton();
        agendaConsulta = new javax.swing.JButton();
        agendaExame = new javax.swing.JButton();
        fechar = new javax.swing.JButton();
        botaoAgendamento = new javax.swing.JButton();
        botaoAutorizar = new javax.swing.JButton();
        panelTela = new javax.swing.JPanel();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jPanel1.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
        jPanel1.setPreferredSize(new java.awt.Dimension(545, 379));

        jButton1.setText("Paciente");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        agendaConsulta.setText("Agendar Consulta");
        agendaConsulta.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                agendaConsultaActionPerformed(evt);
            }
        });

        agendaExame.setText("Agendar Exame");
        agendaExame.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                agendaExameActionPerformed(evt);
            }
        });

        fechar.setText("Fechar Tudo");
        fechar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                fecharActionPerformed(evt);
            }
        });

        botaoAgendamento.setText("Agendamentos");
        botaoAgendamento.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                botaoAgendamentoActionPerformed(evt);
            }
        });

        botaoAutorizar.setText("Autorização");
        botaoAutorizar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                botaoAutorizarActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(10, 10, 10)
                .addComponent(jButton1)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(9, 9, 9)
                        .addComponent(agendaConsulta))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(agendaExame, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                .addGap(18, 18, 18)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(botaoAutorizar, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(botaoAgendamento, javax.swing.GroupLayout.DEFAULT_SIZE, 114, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 85, Short.MAX_VALUE)
                .addComponent(fechar)
                .addGap(54, 54, 54))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jButton1)
                            .addComponent(agendaConsulta)
                            .addComponent(botaoAutorizar))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(botaoAgendamento)
                            .addComponent(agendaExame)))
                    .addComponent(fechar, javax.swing.GroupLayout.PREFERRED_SIZE, 49, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        panelTela.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));

        javax.swing.GroupLayout panelTelaLayout = new javax.swing.GroupLayout(panelTela);
        panelTela.setLayout(panelTelaLayout);
        panelTelaLayout.setHorizontalGroup(
            panelTelaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 575, Short.MAX_VALUE)
        );
        panelTelaLayout.setVerticalGroup(
            panelTelaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 456, Short.MAX_VALUE)
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, 577, Short.MAX_VALUE)
            .addComponent(panelTela, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 76, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(panelTela, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        JPanel pp = PanelPaciente.getPanel();
        panelTela.removeAll(); //remove todos os elementos do panel
        panelTela.setLayout(new BorderLayout()); //define o layout
        panelTela.add(pp,BorderLayout.NORTH); //adiciona a tela
        panelTela.repaint(); //redesenha o panel
        panelTela.validate();
        System.out.println("adicionado ao panel tela");
    }//GEN-LAST:event_jButton1ActionPerformed

    private void fecharActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_fecharActionPerformed
        panelTela.removeAll(); //remove todos os elementos do panel
        panelTela.repaint(); //redesenha o panel
        panelTela.validate();
    }//GEN-LAST:event_fecharActionPerformed

    private void agendaConsultaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_agendaConsultaActionPerformed
        JPanel panel = PanelAtendimentoConsulta.getPanel();
        panelTela.removeAll(); //remove todos os elementos do panel
        panelTela.setLayout(new BorderLayout()); //define o layout
        panelTela.add(panel,BorderLayout.NORTH); //adiciona a tela
        panelTela.repaint(); //redesenha o panel
        panelTela.validate();
        System.out.println("tela de consulta aberta");
    }//GEN-LAST:event_agendaConsultaActionPerformed

    private void agendaExameActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_agendaExameActionPerformed
        JPanel panel = PanelAtendimentoExame.getPanel();
        panelTela.removeAll(); //remove todos os elementos do panel
        panelTela.setLayout(new BorderLayout()); //define o layout
        panelTela.add(panel,BorderLayout.NORTH); //adiciona a tela
        panelTela.repaint(); //redesenha o panel
        panelTela.validate();
    }//GEN-LAST:event_agendaExameActionPerformed

    private void botaoAgendamentoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_botaoAgendamentoActionPerformed
        JPanel panel = PanelAtendimentos.getPanel();
        panelTela.removeAll(); //remove todos os elementos do panel
        panelTela.setLayout(new BorderLayout()); //define o layout
        panelTela.add(panel,BorderLayout.NORTH); //adiciona a tela
        panelTela.repaint(); //redesenha o panel
        panelTela.validate();
    }//GEN-LAST:event_botaoAgendamentoActionPerformed

    private void botaoAutorizarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_botaoAutorizarActionPerformed
        JPanel panel = PanelAutorizacao.getPanel();
        panelTela.removeAll(); //remove todos os elementos do panel
        panelTela.setLayout(new BorderLayout()); //define o layout
        panelTela.add(panel,BorderLayout.NORTH); //adiciona a tela
        panelTela.repaint(); //redesenha o panel
        panelTela.validate();
    }//GEN-LAST:event_botaoAutorizarActionPerformed

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                Main janela = new Main("OOgenda");
                janela.setVisible(true);
                janela.setDefaultCloseOperation(EXIT_ON_CLOSE);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton agendaConsulta;
    private javax.swing.JButton agendaExame;
    private javax.swing.JButton botaoAgendamento;
    private javax.swing.JButton botaoAutorizar;
    private javax.swing.JButton fechar;
    private javax.swing.JButton jButton1;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel panelTela;
    // End of variables declaration//GEN-END:variables

}
